package com.ss.task.test;
/**
 * Created by lifangfang on 2015/9/27.
 */
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.Notification;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.JPushClient;

public class jPush {

    public static PushPayload buildPushAllPayload(String alert) {
        return PushPayload.alertAll(alert);
    }
    public static PushPayload buildIOSPayload(String alias,String alert) {
        return PushPayload.newBuilder()
                .setPlatform(Platform.ios_winphone())
                .setAudience(Audience.alias(alias.replace(".", "_")))
                .setNotification(Notification.newBuilder()
                        .setAlert(alert)
                        .build())
                .build();
    }
    public static PushPayload buildAndroidWinphonePayload(String alias,
                                                          String alert,String title) {
        return PushPayload.newBuilder()
                .setPlatform(Platform.android())
                .setAudience(Audience.alias(alias.replace(".", "_")))
                .setNotification(Notification.newBuilder()
                        .setAlert(alert)
                        .addPlatformNotification(AndroidNotification.newBuilder()
                                .setTitle(title).build())
                        .build())
                .build();
    }
    public static void main(String[] s){
        String appKey="a6dad0d883b5713ae7a2ec8c";
        String masterSecret="4be6e04738656fc187e9b9e3";
        PushPayload ppla=buildPushAllPayload("niyouxindexiaoxi");
        try {
            JPushClient jPushClient = new JPushClient(masterSecret,appKey,3);
            jPushClient.sendPush(ppla);
        }
        catch (Exception e){
            e.printStackTrace();
        }

    }

}